<template>
  <van-button type="primary" @click="popupshow = true"> 创建游戏 </van-button>
  <van-popup
    v-model:show="popupshow"
    position="bottom"
    :style="{ height: '50%' }"
  >
    <div>创建游戏</div>
    <van-cell-group inset>
      <van-field
        v-model="gamedesc"
        label="游戏说明"
        placeholder="请输入游戏说明"
      />
      <div class="van-cell van-field">
        <div class="van-cell__title van-field__label">游戏类型</div>
        <van-radio-group v-model="gametype" direction="horizontal">
          <van-radio name="Jielong">接龙</van-radio>
          <van-radio name="Feihualing">飞花令</van-radio>
          <van-radio name="Duishi">对诗</van-radio>
        </van-radio-group>
      </div>
      <div class="van-cell van-field">
        <div class="van-cell__title van-field__label">回答类型</div>
        <van-radio-group v-model="playtype" direction="horizontal">
          <van-radio name="inturn">轮流</van-radio>
          <van-radio name="fcfa">抢答</van-radio>
        </van-radio-group>
      </div>
      <van-field
        v-model="gamecontext"
        label="游戏条件"
        placeholder="请输入游戏条件"
      />
      <van-button type="secondary" @click="popupshow = false">
        关闭
      </van-button>
      <van-button type="success" data-bs-dismiss="modal" @click="add()">
        保存
      </van-button>
    </van-cell-group>
  </van-popup>
</template>
<script>
export default {
  emits: ["submit"],
  data() {
    return {
      popupshow: false,
      gamedesc: " ",
      gametype: "Duishi",
      gamecontext: "",
      playtype: "inturn",
    };
  },
  methods: {
    createGame: function () {
      this.popupshow = true;
    },
    cancle: function () {
      this.popupshow = false;
    },
    add: function () {
      this.popupshow = false;
      this.$emit("submit", {
        gameDesc: this.gamedesc,
        gameType: this.gametype,
        playtype: this.playtype,
        gameContext: this.gamecontext,
      });
      this.gamedesc = "";
      this.gametype = "Duishi";
      this.gamecontext = "";
    },
  },
};
</script>
